<?php
/**
 * This file contains the class MemberView which provides
 * all of the text requirements for the Member page
 *
 * @copyright  2009 A Memory Tree
 * @license    A Memory Tree License
 */
/*. require_module 'pcre'; .*/
/**
 * This class provides the text for MemberView
 *
 * @copyright  2009 A Memory Tree
 * @license    A Memory Tree License
 */
class MemberView
{
    /**
     * A place to store pre-prepared messages
     *
     * @var array[string]string
     */
    private $_text;
    /**
      * The html class that provides helpers to display the text
     *
     * @var Html
     */
    private $_html;
    /**
     * Builds the list of text messages
     * 
     * @return void
     * @param Html &$html
     */
    function __construct(&$html)
    {
        $this->_html = $html;
        $this->_text['loginFailed'] = '<h2>Log in failed</h2><p class="error">Please try again.</p>';
        $this->_text['changed'] = 'Password Changed.<br />';
        $this->_text['unchanged'] = 'New Password Repeat Does Not Match! Please Try Again.<br />';
        $this->_text['incorrect'] = 'Old Password Incorrect! No Changes Made.<br />';
        $this->_text['badUsername'] = '<p>The entered username was not found.</p>';
        $this->_text['adminControlLink'] = '<a href="/admin/search3.php" target="_new">Admin Control</a><br />';
        $this->_text['addListingHeading'] = '<h5 style="color:#000000;font-family:Georgia,serif;font-size:11pt;line-height:16px;">Remembrance Pages</h5>';
        $this->_text['addListingLink'] = '<a href="/fdsubmit.php">Add Listing</a><br />';
        $this->_text['historyHeading'] = '<h5 style="color:#000000;font-family:Georgia,serif;font-size:11pt;line-height:16px;">Your History</h5>';
        $this->_text['historyLink'] = '<a href="/history.php">View History</a><br />';
        $this->_text['alertsHeading'] = '<h5 style="color:#000000;font-family:Georgia,serif;font-size:11pt;line-height:16px;">Email Alerts</h5>';
        $this->_text['manageAlertsLink'] = '<a href="/alerts.php">Manage Alerts</a><br />';
        $this->_text['addAlertsLink'] = '<a href="/alerts.php?action=new">Add Alerts</a><br />';
        $this->_text['optionsHeading'] = '<h5 style="color:#000000;font-family:Georgia,serif;font-size:11pt;line-height:16px;">Options</h5>';
        $this->_text['passwordLink'] = '<a href="/member.php?action=options">Manage Password</a><br /><br />';
        $this->_text['memberContactHeading'] = '<h5 style="color:#000000;font-family:Georgia,serif;font-size:11pt;line-height:16px;">Contact Us</h5>';
        $this->_text['deathNoticeContactLink'] = '<a href="/membercontact.php?topic=submitnotice">Submit Death Notice</a><br />';
        $this->_text['adminContactLink'] = '<a href="membercontact.php??topic=contactadmin">Contact Administrator</a><br />';
        $this->_text['feedbackContactLink'] = '<a href="/membercontact.php?topic=submitfeedback">Submit Feedback</a><br />';
    }
    /**
     * Return the text that's associated with the given name
     * 
     * @return string
     * @param string $name
     */
    function text($name)
    {
        return $this->_text[$name];
    }
    /** The form to change a persons password
     *
     * @return string
     */
    function changePasswordForm()
    {
        return <<< EOT
    <form action="member.php" method="post">
        <h3 style="padding:2px;">
            Change Password
            <input type="hidden" name="action" value="changepw" />
        </h3>
        <p>
            <label>Old Password: </label>
            <input type="password" name="oldPassword" />
        </p>
        <p>
            <label>New Password: </label>
            <input type="password" name="newPassword" />
        </p>
        <p>
            <label>Repeat New Password: </label>
            <input type="password" name="confirmPassword" />
        </p>
        <p>
            <input type="submit" class="button" value="Change Password" />
        </p>
    </form>
        
EOT;
    }
    /** The logout form
     *
     * @return string
     */
    function logoutForm()
    {
        return <<< EOT
    <tr>
        <td align="right">
            <form action="member.php" method="post">
                <p>
                    <input type="submit" name="logout" value="Logout" class="button" />
                </p>
            </form>
        </td>
    </tr>

EOT;
    }
    /** The form to login with
     *
     * @return string
     * @param string $username
     */
    function loginForm($username)
    {
        $html = $this->_html;
        return <<< EOT
        <form id="login" action="member.php" method="post">
            <h2>User Login</h2>
            <p>
                <input type="hidden" name="action" value="login" />
                <label>Username/Email: </label>
                <input name="username" value="$username" />
            </p>
            <p>
                <label>Password: </label>
                <input type="password" name="password" />
            </p>
            <p><input type="submit" class="button" value="Login" /></p>
            <p><a href="resetPassword.php">I forgot my username/password</a></p>
        </form>

EOT;
    }
    /**
     * Show the welcome message
     *
     * @return string
     * @param string $funeralHomeName
     */
    function welcome($funeralHomeName)
    {
        return <<< EOT
        <h3>Welcome $funeralHomeName</h3><br />

EOT;
    }
    /**
     * Show the member options
     *
     * @return string
     * @param string $permissionLinks
     * @param string $alertLinks
     * @param string $contactLinks
     * @param string $optionLinks
     * @param string $logoutForm
     */
    function memberOptions($permissionLinks, $alertLinks, $contactLinks, $optionLinks, $logoutForm)
    {
        return <<< EOT
    
        <table width="200">
            <tr>
                <td align="left">
                    $permissionLinks
                    $alertLinks
                    $contactLinks
                    $optionLinks
                </td>
            </tr>
            $logoutForm
        </table>
    

EOT;
    }
    /**
     * The authentication success message
     *
     * @return string
     * @param string $authCode
     */
    function authenticationSuccess($authCode)
    {
        return <<< EOT
                <input type="hidden" name="auth" value="$authCode" />
                <h2 style="padding:2px;">Account Authentication</h2>
                <p>Email authentication complete.</p>
                <h2>Set your Password</h2>
EOT;
    }
    /**
     * The authentication failed message
     *
     * @return string
     */
    function authenticationFailure()
    {
        return <<< EOT
                <h2 style="padding:2px;">Account Authentication</h2>
                <p>Email authentication failed.</p>
                <p>Please follow the link about having forgot your password.</p>
EOT;
    }
    /**
     * Show the page contents
     *
     * @return string
     * @param string $text
     */
    function render($text)
    {
        return <<< EOT
    <div id="centerbar">
        $text
    </div>

EOT;
    }
}
?>